import 'package:flutter/material.dart';
import '../models/stock_item.dart';

class StockEntryList extends StatelessWidget {
  final List<StockItem> items;
  final Function(StockItem) onItemRemoved;

  const StockEntryList({
    Key? key,
    required this.items,
    required this.onItemRemoved,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: items.length,
      itemBuilder: (context, index) {
        final item = items[index];
        return Card(
          child: ListTile(
            title: Text(item.name),
            subtitle: Text(
              '${item.category} - ${item.quantity} ${item.unit} - ¥${item.price.toStringAsFixed(2)}',
            ),
            trailing: Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  '¥${(item.price * item.quantity).toStringAsFixed(2)}',
                  style: const TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 16,
                  ),
                ),
                IconButton(
                  icon: const Icon(Icons.delete),
                  onPressed: () => onItemRemoved(item),
                  color: Colors.red,
                ),
              ],
            ),
          ),
        );
      },
    );
  }
} 